package com.warm.dataobject;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.warm.enums.ProductStatusEnum;
import com.warm.utils.EnumUtil;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by liangchuang on 2018/9/3.
 */
@Entity
@DynamicUpdate
@Data
public class ProductInfo implements Serializable{

    private static final long serialVersionUID = -8061369944362730191L;

    @Id
    private String productId;

    private String productName;

    private BigDecimal productPrice;

    private Integer productStock;

    private String productDescription;

    private String productIcon;

    //状态 0-正常 1-下架
    private Integer productStatus = ProductStatusEnum.UP.getCode();

    //类目编号
    private Integer categoryType;

    private Date createTime;

    private Date updateTime;

    @JsonIgnore
    public ProductStatusEnum getProductStatusEnum(){
        return EnumUtil.getByCode(productStatus,ProductStatusEnum.class);
    }
}
